package thinkinginjava.IO;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.imageio.stream.FileImageInputStream;

public class StoringAndRecoveringData {
	public static void main(String[] args) throws IOException {
		DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
				new FileOutputStream("Data.txt")));
		out.writeDouble(3.1415926);
		out.writeUTF("That is pi");
		out.writeInt(-129);
		out.writeUTF("That is pi again");

		out.close();
		DataInputStream in = new DataInputStream(new BufferedInputStream(
				new FileInputStream("Data.txt")));
		System.out.println(in.readDouble());
		System.out.println(in.readUTF());
		System.out.println(in.readInt());
		System.out.println(in.readUTF());

	}
}
